var $placedetail 	= $('#place'),
	serverUrl	= 'http://localhost/zigo/server/place.php/';
	
PlaceDetail = Backbone.Model.extend({
	
});

PlaceDetailCollection = Backbone.Collection.extend({
	model: PlaceDetail,
	url: serverUrl + 'place/' + document.URL.split('place_id=')[1]
});

PlaceDetailViewItem = Backbone.View.extend({
	tagName: 'div',
	initialize: function() {
		this.render = _.bind(this.render, this);
		this.template = _.template($('#place-item').html());
		//this.model.bind('change', this.render);
	},
	render: function() {
		this.$el.html(this.template(this.model.attributes));
		return this;
	}
});
PlaceDetailList = Backbone.View.extend({
	initialize: function() {
		_(this).bindAll('add');

		this._placedetail = [];
		
		this.collection.each(this.add);
		
		this.collection.bind('add', this.add);
	},
	render: function() {
		this._rendered = true;
		this.$el.empty();
		_(this._placedetail).each(function(item) {
			$placedetail.append(item.render().el);
		});
	},
	add: function(place) {
		var placeDetailItem = new PlaceDetailViewItem({model: place});

		this._placedetail.push(placeDetailItem);

		if (this._rendered) {
			this.$el.append(placeDetailItem.render().el);
		}
	}
});